﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Downloader.Domain;
using Downloader.Domain.Contracts.Tasks;
using SharpArch.Domain.PersistenceSupport;

namespace Downloader.Tasks
{
   public class WebSiteInfoTasks:IWebSiteInfoTasks
    {
       private readonly IRepository<WebSiteInfo> websiteRepository; 
       public WebSiteInfoTasks(IRepository<WebSiteInfo> repository)
       {
           websiteRepository = repository;
       }

        public List<Domain.WebSiteInfo> GetAll()
        {
            return websiteRepository.GetAll().OrderBy(c => c.CreateTime).ToList();
        }

        public Domain.WebSiteInfo Get(int id)
        {
            return websiteRepository.Get(id);
        }

        public Domain.WebSiteInfo CreateOrUpdate(Domain.WebSiteInfo articleContent)
        {
            return websiteRepository.SaveOrUpdate(articleContent);
        }

        public void Delete(int id)
        {
            var entiry= websiteRepository.Get(id);
            websiteRepository.Delete(entiry);
        }

 
    }
}
